<template>
  <view>
    <audio id="audio" :src="src" :poster="poster" :name="name" :author="author" controls></audio>
    <button @click="setSrc">setSrc</button>
    <button @click="play">play</button>
    <button @click="seek">seek</button>
    <button @click="pause">pause</button>
  </view>
</template>

<script>
let context

export default {
  data () {
    return {
      poster: 'https://img-cdn-qiniu.dcloud.net.cn/uniapp/audio/music.jpg',
      name: '致爱丽丝',
      author: '暂无',
      src: 'https://vkceyugu.cdn.bspapp.com/VKCEYUGU-hello-uniapp/2cc220e0-c27a-11ea-9dfb-6da8e309e0d8.mp3',
    }
  },
  onReady () {
    context = uni.createAudioContext('audio', this)
  },
  methods: {
    setSrc () {
      context.setSrc('https://vkceyugu.cdn.bspapp.com/VKCEYUGU-hello-uniapp/2cc220e0-c27a-11ea-9dfb-6da8e309e0d8.mp3')
      return 'success'
    },
    play () {
      context.play()
      return 'success'
    },
    seek () {
      context.seek(0)
      return 'success'
    },
    pause () {
      context.pause()
      return 'success'
    }
  }
}
</script>

<style>
</style>